'''
Created on 2009-5-15

@author: Administrator
'''
import unittest
from com.carnation.common.util.test import testTools


class Test(unittest.TestCase):
    def testCreate(self):
        test = testTools(__file__) 
        rsp_msg = test.requestAndRsp(1, 'Run For Test DataService.create', \
'''
DataService.create
    MOIData
        setModelId    "Model=8"
        setName    "pythontest"
        setParentId    null
        setDisplayName    "pythontest"
''', \
'''
MOIData
    getName    "pythontest"
    getModelId    "Model=8"
    getParentId    null
    getDisplayName    "pythontest"
'''
)
        print rsp_msg
        print '\nDone'
        test.quit()

    def testDelete(self):
        test = testTools(__file__) 
        rsp_msg = test.requestAndRsp(2, 'Run For Test DataService.delete', \
'''
DataService.delete
    MOIData
        setId    "OlapServer=2"
''', \
'''
true
'''
)
        print rsp_msg
        rsp_msg = test.requestAndRsp(3, 'Run For Test DataService.delete', \
'''
DataService.delete
    String    "Model=8"
''', \
'''true'''
)
        print '\nDone'
        test.quit()

    def testGetChildNodes(self):
        test = testTools(__file__) 
        rsp_msg = test.requestAndRsp(4, 'Run For Test DataService.getChildNodes', \
'''
DataService.getChildNodes
    String    "Catalog=1"
''', \
'''
java.util.List
    0
        MOINode
            getId    "Schema=1"
            getName    "schema"
    1
        MOINode
            getId    "Schema=2"
            getName    "schema1"
    2
        MOINode
            getId    "Schema=3"
            getName    "schema2"
'''
)
        print rsp_msg
        rsp_msg = test.requestAndRsp(5, 'Run For Test DataService.getChildNodes', \
'''
DataService.getChildNodes
    String    "Catalog=1"
    int    0
    int    100
''', \
'''
java.util.List
    0
        MOINode
            getId    "Schema=1"
            getName    "schema"
    1
        MOINode
            getId    "Schema=2"
            getName    "schema1"
    2
        MOINode
            getId    "Schema=3"
            getName    "schema2"
'''
)
        print rsp_msg
        print '\nDone'
        test.quit()

    def testGetChildren(self):
        test = testTools(__file__) 
        rsp_msg = test.requestAndRsp(6, 'Run For Test DataService.getChildren', \
'''
DataService.getChildren
    MOIData
        setId    "Catalog=1"
''', \
'''
java.util.List
    0
        MOIData
            getId    "Schema=1"
            getName    "schema"
    1
        MOIData
            getId    "Schema=2"
            getName    "schema1"
    2
        MOIData
            getId    "Schema=3"
            getName    "schema2"
'''
)
        print rsp_msg
        rsp_msg = test.requestAndRsp(7, 'Run For Test DataService.getChildren', \
'''
DataService.getChildren
    String    "Catalog=1"
''', \
'''
java.util.List
    0
        MOIData
            getId    "Schema=1"
            getName    "schema"
    1
        MOIData
            getId    "Schema=2"
            getName    "schema1"
    2
        MOIData
            getId    "Schema=3"
            getName    "schema2"
'''
)
        print rsp_msg
        rsp_msg = test.requestAndRsp(8, 'Run For Test DataService.getChildren', \
'''
DataService.getChildren
    String    "Catalog=1"
    int    0
    int    100
''', \
'''
java.util.List
    0
        MOINode
            getId    "Schema=1"
            getName    "schema"
    1
        MOINode
            getId    "Schema=2"
            getName    "schema1"
    2
        MOINode
            getId    "Schema=3"
            getName    "schema2"
'''
)
        print rsp_msg
        print '\nDone'
        test.quit()

if __name__ == "__main__":
    unittest.main()

